public class Test {
    public static void main(String[] args) {
        MyBlokingQueue blokingQueue = new MyBlokingQueue(1000);
        Thread t1 = new Thread(()->{
            int i = 1;
            while(true){
                try {
                    blokingQueue.put(""+i);
                    System.out.println("生产元素"+i);
                    i++;
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

            }
        });
        Thread t2 = new Thread(()->{
            while(true){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                try {
                    Integer i = Integer.parseInt(blokingQueue.take());
                    System.out.println("消费者"+i);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t1.start();
        t2.start();
    }
}
